﻿@inherits MasaComponentBase

<SModal @key="@ModalKey" Width="684" Title="@T("Rollback")" Value="Value" ValueChanged="ValueChanged" HideCancelAction OnSave="HandOnClickAsync" BodyStyle="padding-top: 0px">
    <ChildContent>
        <MAlert Dense
                Type="AlertTypes.Warning">
            @T("RollBackAlertMessage")
        </MAlert>
        <MTimeline Style="position:relative; left:-252px;">
            <MTimelineItem Color="primary" Small Right FillDot>
                <OppositeContent>
                    <div>
                        <div style="font-size:14px; font-weight: 500; color: #1B2559;">
                            <DateTimeZone Value="CurrentConfigObjectRelease.CreationTime" Format="@(d=>d.ToString("MM.dd").TrimStart('0'))" />
                        </div>
                        <div style="font-size:10px; font-weight: 400; color: #A3AED0;">@T("Current")</div>
                    </div>
                </OppositeContent>
                <ChildContent>
                    <div>
                        <div style="font-size:14px; font-weight: 500; color: #1B2559;">@CurrentConfigObjectRelease.Name</div>
                    </div>
                </ChildContent>
            </MTimelineItem>
            <MTimelineItem Color="primary" Small Right FillDot>
                <OppositeContent>
                    <div style="font-size:14px; font-weight: 500; color: #1B2559; width: 48px; float: right;">@T("Rollback to")</div>
                </OppositeContent>
                <ChildContent>
                    <div>
                        <div style="font-size:14px; font-weight: 500; color: #1B2559;">@RollbackConfigObjectRelease.Name</div>
                    </div>
                </ChildContent>
            </MTimelineItem>
        </MTimeline>
        @if (FormatLabelCode.ToLower() == "properties")
        {
            <div style="border-radius:8px; border:1px solid #E2E7F4;" class="pb-3 pt-1 mt-4">
                <MDataTable Headers="_headers"
                        TItem="ConfigObjectPropertyModel"
                        Items="@_properties"
                        Class="table-header-border-1"
                        DisableSort
                        HideDefaultFooter>
                    <HeaderColContent Context="header">
                        <span class="regular3--text btn">@T(header.Text)</span>
                    </HeaderColContent>
                    <ItemColContent>
                        @switch (@context.Header.Text)
                        {
                            case "State":
                                if (context.Item.IsAdded)
                                {
                                    <SIcon Class="mr-1" Color="#7681AB" Style="margin-bottom:2px;" Size="16">mdi-plus</SIcon>
                                }
                                else if (context.Item.IsEdited)
                                {
                                    <SIcon Class="mr-1" Color="#7681AB" Style="margin-bottom:2px;" Size="16">mdi-pencil</SIcon>
                                }
                                else if (context.Item.IsDeleted)
                                {
                                    <SIcon Class="mr-1" Color="#7681AB" Style="margin-bottom:2px;" Size="16">mdi-delete</SIcon>
                                }
                                break;
                            default:
                                @context.Value
                                break;
                        }
                    </ItemColContent>
                </MDataTable>
            </div>
        }
        else
        {
            <div class="py-3">
                <MRow NoGutters>
                    <MTextarea Label="@(T("Before rollback"))" Class="rounded-r-0" TextColor="emphasis2" MinHeight="300" HideDetails="true" Outlined Readonly Value="@CurrentConfigObjectRelease?.Content"></MTextarea>
                    <MTextarea Label="@(T("After rollback"))" Class="rounded-l-0" TextColor="emphasis2" MinHeight="300" HideDetails="true" Outlined Readonly Value="@RollbackConfigObjectRelease?.Content"></MTextarea>
                </MRow>
            </div>
        }
    </ChildContent>
    <SaveContent Context="save">
        <SButton Small OnClick="save.Click" Style="float:right;">@T("Rollback")</SButton>
    </SaveContent>
</SModal>